#include <iostream>
#include <tuple>
#include <algorithm>
#include <cassert>
#include <vector>

const int N = 1e5 + 5;
const int M = 1e7 + 5;

int n, q, m = 1e9;
int a[N], b[N], c[N], d[N];
int rt, tt, mi[M], lazy[M], cnt[M], ls[M], rs[M];
int st1[18][N], st2[18][N], lg2[N];

inline int newnode(int len) {
	int o = ++tt;
	mi[o] = lazy[o] = 0;
	ls[o] = rs[o] = 0;
	cnt[o] = len;
	return o;
}

inline void pushup(int o) {
	assert(ls[o] && rs[o]);
	if(mi[ls[o]] == mi[rs[o]]) {
		mi[o] = mi[ls[o]] + lazy[o];
		cnt[o] = cnt[ls[o]] + cnt[rs[o]];
	} else if(mi[ls[o]] < mi[rs[o]]) {
		mi[o] = mi[ls[o]] + lazy[o];
		cnt[o] = cnt[ls[o]];
	} else {
		mi[o] = mi[rs[o]] + lazy[o];
		cnt[o] = cnt[rs[o]];
	}
}

inline void setlazy(int o, int x) {
	lazy[o] += x;
	mi[o] += x;
}

inline void add(int& o, int ql, int qr, int x, int l, int r) {
	if(!o) o = newnode(r - l + 1);
	if(ql <= l && r <= qr) {
		setlazy(o, x);
		return;
	}
	int mid = (l + r) >> 1;
	if(!ls[o]) ls[o] = newnode(mid - l + 1);
	if(!rs[o]) rs[o] = newnode(r - mid);
	if(ql <= mid) add(ls[o], ql, qr, x, l, mid);
	if(mid < qr) add(rs[o], ql, qr, x, mid + 1, r);
	pushup(o);
}

void force(int l, int r) {
	rt = tt = 0;
	std::vector<std::tuple<int, int, int, int>> vect;
	for(int i = l; i <= r; ++i) {
		vect.emplace_back(a[i], c[i], d[i], 1);
		vect.emplace_back(b[i] + 1, c[i], d[i], -1);
	}
	std::sort(vect.begin(), vect.end());
	long long ans = 0;
	for(int i = 0; i < vect.size(); ++i) {
		const auto& e = vect[i];
		add(rt, std::get<1>(e), std::get<2>(e), std::get<3>(e), 1, m);
		if(i + 1 < vect.size()) {
			ans += 1ll * (std::get<0>(vect[i+1]) - std::get<0>(vect[i])) * (m - (mi[rt] == 0 ? cnt[rt] : 0));
		}
	}
	std::cout << ans << "\n";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);

	std::freopen("dierti.in", "r", stdin);
	std::freopen("dierti.out", "w", stdout);

	int id;
	std::cin >> id >> n >> q;
	for(int i = 1; i <= n; ++i) {
		std::cin >> a[i] >> c[i] >> b[i] >> d[i];
		--b[i], --d[i];
	}
	if(id < 7 || id > 9) {
		while(q--) {
			int l, r; std::cin >> l >> r;
			force(l, r);
		}
	} else {
		for(int i = 1; i <= n; ++i) st1[0][i] = d[i], st2[0][i] = c[i];
		for(int i = 2; i <= n; ++i) lg2[i] = lg2[i >> 1] + 1;
		for(int j = 1; j <= 17; ++j) {
			for(int i = 1; i + (1 << j) - 1 <= n; ++i) {
				st1[j][i] = std::max(st1[j-1][i], st1[j-1][i+(1<<j-1)]);
				st2[j][i] = std::min(st2[j-1][i], st2[j-1][i+(1<<j-1)]);
			}
		}
		while(q--) {
			int l, r; std::cin >> l >> r;
			if(r - l + 1 <= n / 20) {
				std::vector<std::pair<int, int>> vect;
				vect.reserve(2 * (r - l + 1));
				for(int i = l; i <= r; ++i) {
					vect.emplace_back(c[i], 1);
					vect.emplace_back(d[i] + 1, -1);
				}
				std::sort(vect.begin(), vect.end());
				int ans = 0, c = 0;
				for(int i = 0; i < vect.size(); ++i) {
					c += vect[i].second;
					if(i + 1 < vect.size() && c) ans += vect[i + 1].first - vect[i].first;
				}
				std::cout << ans << "\n";
			} else {
				int i = lg2[r-l+1];
				int mx = std::max(st1[i][l], st1[i][r-(1<<i)+1]);
				int mi = std::min(st2[i][l], st2[i][r-(1<<i)+1]);
				std::cout << mx - mi + 1 << "\n";
			}
		}
	}

	return 0;
}
